home *** CD-ROM | disk | FTP | other *** search
- Path: news.compuserve.com!newsmaster
- From: 100754.2730@compuserve.com (Martin Aupperle)
- Newsgroups: comp.lang.c++
- Subject: Re: Q: Returning a reference
- Date: Fri, 26 Jan 1996 10:01:04 GMT
- Organization: CompuServe Incorporated
- Message-ID: <4ea93s$kq6@dub-news-svc-1.compuserve.com>
- References: <4cvsm2$5ig@dub-news-svc-4.compuserve.com> <30F53184.C57@dinamero.com>
- NNTP-Posting-Host: ad02-055.compuserve.com
- X-Newsreader: Forte Free Agent v0.56
-
- "Robert S. Stull" <stullr@dinamero.com> wrote:
-
-
- >> int &doIt() {
- >>
- >> int i = 7;
- >> return i; // syntax error
- >> }
- >>
-
- [snip]
-
- >Try this:
- > static int i = 7;
- >Most compilers allow it and it will still be valid when you exit
- >the function.
-
- Not only most, but all should allow that - the static variable remains
- alive until the program terminates. No problem so far, because the
- reference always has a object it is bound to, i.e the lifetime of the
- object is equal/longer than that of the reference. But what happens if
- the lifetime of a reference is LONGER than that of the referent?
- Does/should the language allow that?
-
-
-
-
- -----------------------------------
- Signatures are a waste of bandwidth
- -----------------------------------
-
-